package com.wlc.rabbitmq.workqueue;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 王立朝
 * @description 生产者：工作模式-一个生产者，对应多个消费者
 * @date 2021-12-14 20:40:29
 */
@Component
public class WorkProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(){
        for (int i = 0; i < 10; i++) {
            String message = "工作消息" + i;
            System.out.println("我是生产信息的：" + message);
            rabbitTemplate.convertAndSend("work_queue", message);

        }

    }
}
